/*
 * @Author: wang
 * @Date: 2022-07-14 15:18:15
 * @LastEditors: wang
 * @LastEditTime: 2022-07-28 18:15:16
 * @Description: 
 */
import http from './servies'

// 登陆接口
export function loginApi(data:any) {
  return http({
    url: 'login',
    method: 'post',
    data
  })
}

// 菜单栏接口
export const getMenuListApi = () => {
  return http({
    url: 'menus',
    method: 'get',
  })
}

// 获取用户信息列表
export const getUserListApi = (data: any) => {
  return http({
    url: 'users',
    method: 'get',
    params: data
  })
}

// 添加新用户
export const addUserApi = (data: any) => {
  return http({
    url: `users`,
    method: 'post',
    data
  })
}

// 更改用户状态
export const changeUserStatus = (uid: number, type: boolean) => {
  return http({
    url: `users/${uid}/state/${type}`,
    method: 'put',
  })
}

// 根据用户ID获取用户信息
export const getUserById = (uid: number) => {
  return http({
    url: `users/${uid}`,
    method: 'get',
  })
}

// 编辑用户信息
export const editUserApi = (uid: number, data: any) => {
  return http({
    url: `users/${uid}`,
    method: 'put',
    data
  })
}

// 删除用户信息
export const delUserApi = (uid: number) => {
  return http({
    url: `users/${uid}`,
    method: 'delete'
  })
}

// 获取权限列表
export const setRoleApi = (id:number, data:any) => {
  return http({
    url: `users/${id}/role`,
    method: 'put',
    data
  })
}

// 获取权限列表
export const getRolesApi = () => {
  return http({
    url: `roles`,
    method: 'get'
  })
}